#pragma once

#include "../umlmodel_global.h"

#include <memory>
#include <vector>

#include "NamedElement.h"
#include "PseudostateKind.h"
#include "Vertex.h"

using std::make_shared;
using std::shared_ptr;
using std::vector;

namespace uml {
class State;
class StateMachine;

/// <summary>
/// Pseudostate
/// A Pseudostate is an abstraction that encompasses different types of transient
/// Vertices in the StateMachine graph. A StateMachine instance never comes to rest
/// in a Pseudostate, instead, it will exit and enter the Pseudostate within a
/// single run-to-completion step.
/// </summary>
class UMLMODEL_EXPORT Pseudostate : public NamedElement, public Vertex {

public: // Constructors and destructors
    explicit Pseudostate(const QString& umlType="uml::Pseudostate");

public: // JsonSerializable override
    void fromJson(const QJsonObject& json, QStringList& errorList) override;
    void toJson(QJsonObject& json) override;

public: // Properties
    /// <summary>
    /// kind getter
    /// Determines the precise type of the Pseudostate and can be one of: entryPoint,
    /// exitPoint, initial, deepHistory, shallowHistory, join, fork, junction, terminate
    /// or choice.
    /// </summary>
    PseudostateKind kind() const;

    /// <summary>
    /// kind setter
    /// Determines the precise type of the Pseudostate and can be one of: entryPoint,
    /// exitPoint, initial, deepHistory, shallowHistory, join, fork, junction, terminate
    /// or choice.
    /// </summary>
    void setKind(PseudostateKind value);

    /// <summary>
    /// state getter
    /// The State that owns this Pseudostate and in which it appears.
    /// </summary>
    shared_ptr<State> state() const;

    /// <summary>
    /// state setter
    /// The State that owns this Pseudostate and in which it appears.
    /// </summary>
    void setState(shared_ptr<State> value);

    /// <summary>
    /// stateMachine getter
    /// The StateMachine in which this Pseudostate is defined. This only applies to
    /// Pseudostates of the kind entryPoint or exitPoint.
    /// </summary>
    shared_ptr<StateMachine> stateMachine() const;

    /// <summary>
    /// stateMachine setter
    /// The StateMachine in which this Pseudostate is defined. This only applies to
    /// Pseudostates of the kind entryPoint or exitPoint.
    /// </summary>
    void setStateMachine(shared_ptr<StateMachine> value);

private: // Fields
    /// <summary>
    /// kind
    /// Determines the precise type of the Pseudostate and can be one of: entryPoint,
    /// exitPoint, initial, deepHistory, shallowHistory, join, fork, junction, terminate
    /// or choice.
    /// </summary>
    PseudostateKind kind_ = PseudostateKind::kinitial;

    /// <summary>
    /// state
    /// The State that owns this Pseudostate and in which it appears.
    /// </summary>
    shared_ptr<State> state_;

    /// <summary>
    /// stateMachine
    /// The StateMachine in which this Pseudostate is defined. This only applies to
    /// Pseudostates of the kind entryPoint or exitPoint.
    /// </summary>
    shared_ptr<StateMachine> stateMachine_;

};

} // namespace uml
